//
//  CachetUseCell.m
//  云律司
//
//  Created by 韦淋 on 2017/9/7.
//  Copyright © 2017年 test. All rights reserved.
//

#import "CachetUseCell.h"

@implementation CachetUseCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initalizeInterface];
    }
    return self;
}
- (void)initalizeInterface{
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.lineView];
    [self.bgView addSubview:self.titleLable];
    [self.bgView addSubview:self.caseNumLable];
    [self.bgView addSubview:self.recipientLable];
    [self.bgView addSubview:self.bailorLable];
    [self.bgView addSubview:self.sealLable];
    [self.bgView addSubview:self.receivingDateLable];
    [self.bgView addSubview:self.approveStatusLable];
    [self.bgView addSubview:self.alterButton];
    [self.bgView addSubview:self.deleteButton];
    [self.bgView addSubview:self.detailButton];
}
- (void)layoutSubviews{
    
    
    self.bgView.frame = CGRectMake(5, 0, self.contentView.bounds.size.width - 10, self.contentView.bounds.size.height - 15);
    self.lineView.frame = CGRectMake(0, 0, self.bgView.bounds.size.width , 2);
    self.titleLable.frame = CGRectMake(10, 0, 300, 40);
    self.caseNumLable.frame = CGRectMake(40, 40, 350, 25);
    self.recipientLable.frame = CGRectMake(40, 65, 350, 25);
    self.bailorLable.frame = CGRectMake(40, 90, 350, 25);
    self.sealLable.frame = CGRectMake(40, 115, 350, 25);
    self.receivingDateLable.frame = CGRectMake(40, 140, 350, 25);
    self.approveStatusLable.frame = CGRectMake(40, 165, 350, 25);
    self.alterButton.frame = CGRectMake(180, 180, 80, 30);
    self.deleteButton.frame = CGRectMake(280, 180, 80, 30);
    self.detailButton.frame = CGRectMake(280, 180, 80, 30);
    for (int i = 0; i < 6; i ++) {
        UIView *dividerView = [[UIView alloc] initWithFrame:CGRectMake(0, 40 + i * 25, self.bgView.bounds.size.width , 0.5)];
        dividerView.backgroundColor = [UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0f];
        [self.bgView addSubview:dividerView];
        
        NSArray *array = [NSArray array];
        array = @[@"bann_02",@"bann_03",@"bann_04",@"bann_05",@"bann_05",@"bann_05"];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 42 + i * 25, 20, 20)];
        //        imageView.backgroundColor = [UIColor redColor];
        imageView.image = [UIImage imageNamed:array[i]];
        
        [self.bgView addSubview:imageView];
    }
    
    
}
//按钮方法
-(void)didClickAlterButton:(UIButton*)sender
{
    if ([self.delegate respondsToSelector:@selector(didClickAlterButtonAction:)]) {
        [self.delegate didClickAlterButtonAction:sender];
    }
}
-(void)didClickDeleteButton:(UIButton*)sender
{
    
    if ([self.delegate respondsToSelector:@selector(didClickDeleteButtonAction:)]) {
        [self.delegate didClickDeleteButtonAction:sender];
    }
}
-(void)didClickDetailButton:(UIButton*)sender
{
    if ([self.delegate respondsToSelector:@selector(didClickDetailButtonAction:)]) {
        [self.delegate didClickDetailButtonAction:sender];
    }
}
- (UIView *)bgView{
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = [UIColor colorWithRed:248.0f/255.0f green:248.0f/255.0f blue:248.0f/255.0f alpha:1.0f];
        _bgView.layer.shadowColor=[UIColor lightGrayColor].CGColor;
        _bgView.layer.shadowOffset=CGSizeMake(3, 3);
        _bgView.layer.shadowOpacity=0.5;
    }
    return _bgView;
}
- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = [UIColor colorWithRed:63.0f/255.0f green:189.0f/255.0f blue:240.0f/255.0f alpha:1.0f];
    }
    return _lineView;
}
- (UILabel *)titleLable{
    if (!_titleLable) {
        _titleLable = [[UILabel alloc]init];
        _titleLable.textColor = [UIColor blackColor];
        _titleLable.font = [UIFont systemFontOfSize:16];
    }
    return _titleLable;
}
- (UILabel *)caseNumLable{
    if (!_caseNumLable) {
        _caseNumLable = [[UILabel alloc]init];
        _caseNumLable.textColor = [UIColor blackColor];
        _caseNumLable.font = [UIFont systemFontOfSize:11];
        _caseNumLable.numberOfLines = 2;
        _caseNumLable.lineBreakMode = NSLineBreakByTruncatingTail;
    }
    return _caseNumLable;
}
- (UILabel *)recipientLable{
    if (!_recipientLable) {
        _recipientLable = [[UILabel alloc]init];
        _recipientLable.textColor = [UIColor blackColor];
        _recipientLable.font = [UIFont systemFontOfSize:11];
    }
    return _recipientLable;
}
- (UILabel *)bailorLable{
    if (!_bailorLable) {
        _bailorLable = [[UILabel alloc]init];
        _bailorLable.textColor = [UIColor blackColor];
        _bailorLable.font = [UIFont systemFontOfSize:11];
    }
    return _bailorLable;
}

- (UILabel *)sealLable{
    if (!_sealLable) {
        _sealLable = [[UILabel alloc]init];
        _sealLable.textColor = [UIColor blackColor];
        _sealLable.font = [UIFont systemFontOfSize:11];
        
    }
    return _sealLable;
}
- (UILabel *)receivingDateLable{
    if (!_receivingDateLable) {
        _receivingDateLable = [[UILabel alloc]init];
        _receivingDateLable.textColor = [UIColor blackColor];
        _receivingDateLable.font = [UIFont systemFontOfSize:11];
    }
    return _receivingDateLable;
}
- (UILabel *)approveStatusLable{
    if (!_approveStatusLable) {
        _approveStatusLable = [[UILabel alloc]init];
        _approveStatusLable.textColor = [UIColor blackColor];
        _approveStatusLable.font = [UIFont systemFontOfSize:11];
    }
    return _approveStatusLable;
}
- (UIButton *)alterButton{
    if (!_alterButton) {
        _alterButton = [[UIButton alloc]init];
        [_alterButton setTitle:@"修改" forState:0];
        _alterButton.layer.masksToBounds = YES;
        _alterButton.layer.cornerRadius = 5;
        _alterButton.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
        [_alterButton addTarget:self action:@selector(didClickAlterButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _alterButton;
}
- (UIButton *)deleteButton{
    if (!_deleteButton) {
        _deleteButton = [[UIButton alloc]init];
        [_deleteButton setTitle:@"删除" forState:0];
        _deleteButton.layer.masksToBounds = YES;
        _deleteButton.layer.cornerRadius = 5;
        _deleteButton.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
        [_deleteButton addTarget:self action:@selector(didClickDeleteButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _deleteButton;
}
- (UIButton *)detailButton{
    if (!_detailButton) {
        _detailButton = [[UIButton alloc]init];
        [_detailButton setTitle:@"查看详情" forState:0];
        _detailButton.layer.masksToBounds = YES;
        _detailButton.layer.cornerRadius = 5;
        _detailButton.backgroundColor = [UIColor colorWithRed:33.0f/255.0f green:180.0f/255.0f blue:237.0f/255.0f alpha:1.0f];
        [_detailButton addTarget:self action:@selector(didClickDetailButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _detailButton;
}
@end
